<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/10/9 0009
 * Time: 下午 5:53
 */
namespace app\article\controller\compose;
use app\common\api\AApi;
use app\common\api\article\IComment;
use app\common\api\article\ICompose;
use app\common\api\article\IReply;

class Api extends AApi implements ICompose,IComment,IReply {
    #初始化配置
    public function __construct(array $config = []){
        parent::__construct();
    }
    #用户对象
    static public $obj;

    /**
     * 单列实例化模式
     */
    static function getCompose(){
        $data = self::$post_data;
        self::$obj = new Compose($data);
        return self::$obj;
    }
    //文章
    /**
     * 文章列表
     * @return array|string
     */
    public function cp_list(){
        $obj = self::getCompose();
        $res = $obj->cp_list();
        return create_callback($res);
    }

    /**
     * 个人文章列表
     * @return array|string
     */
    public function cp_info_list(){
        $obj = self::getCompose();
        $res = $obj->cp_info_list();
        return create_callback($res);
    }

    /**
     * 精确到某一篇文章
     * @return array|string
     */
    public function cp_info(){
        $obj = self::getCompose();
        $res = $obj->cp_info();
        return create_callback($res);
    }

    /**
     * 文章类型分类
     */
    public function cp_type()
    {
        $obj = self::getCompose();
        $res = $obj->cp_type();
        return create_callback($res);
    }

    /**
     * 文章时间分类
     */
    public function cp_time()
    {
        $obj = self::getCompose();
        $res = $obj->cp_time();
        return create_callback($res);
    }

    /**
     * 添加文章
     * @return array|string
     */
    public function cp_add(){
        $obj = self::getCompose();
        $res = $obj->cp_add();
        return create_callback($res);
    }

    /**
     * 修改文章
     * @return array|string
     */
    public function cp_update(){
        $obj = self::getCompose();
        $res = $obj->cp_update();
        return create_callback($res);
    }

    //评论
    static function getComment(){
        $data = self::$post_data;
        self::$obj = new Comment($data);
        return self::$obj;
    }

    /**
     * 添加评论
     * @return array|string
     */
    public function cm_add(){
        $obj = self::getComment();
        $res = $obj-> cm_add();
        return create_callback($res);
    }

    /**
     * 个人删除评论
     * @return array|string
     */
    public function cm_del(){
        $obj = self::getComment();
        $res = $obj-> cm_del();
        return create_callback($res);
    }


    /**
     * 评论列表
     * @return array|string
     */
    public function cm_list()
    {
        $obj = self::getComment();
        $res = $obj-> cm_list();
        return create_callback($res);
    }

    /**
     * 我的文章评论
     * @return array|string
     */
    public function otherCm_list()
    {
        $obj = self::getComment();
        $res = $obj-> otherCm_list();
        return create_callback($res);
    }

    /**
     * 我的发表的评论
     * @return array|string
     */
    public function myCm_list()
    {
        $obj = self::getComment();
        $res = $obj-> myCm_list();
        return create_callback($res);
    }

    //回复
    static function getReply(){
        $data = self::$post_data;
        self::$obj=new Reply($data);
        return self::$obj;
    }
    public function reply_list()
    {
        $obj = self::getReply();
        $res = $obj->reply_list();
        return create_callback($res);
    }
    public function myReply_list(){
        $obj = self::getReply();
        $res = $obj->myReply_list();
        return create_callback($res);
    }

    public function reply_add(){
        $obj = self::getReply();
        $res = $obj->reply_add();
        return create_callback($res);
    }
    public function reply_update(){
        $obj = self::getReply();
        $res = $obj->reply_update();
        return create_callback($res);
    }

}